*********************************
***  Trump paper - Figure 3
*** Created: 31/10/2020
*** Last updated: 21/05/2021
clear all
set scheme plottig
 

	local user = 1		/* user 1 = sergi, user 2 = Anja */

	if `user' == 1 {			// input relevant file path as per your computer

		global		main "/Users/aneundorf/Dropbox/Project_Populism/BA project/Analysis/Trump_Replication files/"
		global 		graphs 			"${main}Graphs/"
		global 		results			"${main}Results/"
	}

cd "${main}"
use "Data/US_data_recoded.dta", clear

global controls2 female  i.educ_cat i.domicile i.ethnic i.religion


*------------------------------------------------------------
*Figure 3
reg trump_vsbiden ib4.Group##c.age $controls2
margins, dydx(i.Group) at(age=(20(5)80))
marginsplot, yline(0) plot2opts(lc(black) mc(black)) ci2opt(lc(black)) plot3opts(lc(none) mc(none)) plot1opts(lc(none) mc(none)) ci1opt(lc(none)) ci3opt(lc(none)) legend(off) yline(0) ytitle("Marginal effect of gov. managment treatment", size(large)) xlabel(, labsize(medsmall)) ylabel(-.5(.1).4, labsize(medsmall)) xtitle("Age", size(medium)) title("A. Linear age effect", size(large)) name(linear, replace)


reg trump_vsbiden ib4.Group##c.age##c.age##c.age $controls2
margins, dydx(i.Group) at(age=(20(5)80))
marginsplot, yline(0) plot2opts(lc(black) mc(black)) ci2opt(lc(black)) plot3opts(lc(none) mc(none)) plot1opts(lc(none) mc(none)) ci1opt(lc(none)) ci3opt(lc(none)) legend(off) yline(0) ytitle("Marginal effect of gov. managment treatment", size(large)) xlabel(, labsize(medsmall)) ylabel(-.5(.1).4, labsize(medsmall)) xtitle("Age", size(medium)) title("B. Non-linear age effect", size(large)) name(nonlinear, replace)


** Create graphs
graph combine linear nonlinear , row(1) graphregion(fcolor(white) lc(black)) xsize(9) ysize(5) 
graph save  "${graphs}Figure3.gph",  replace
graph export  "${graphs}Figure3.pdf", as(pdf) replace
